
		<div class="ui-portlet">
			{{template wxes/_user_wxes}}
			<ol class="breadcrumb">
			  <li><a href="/users/index"><i class="fa fa-home"></i>&nbsp;&nbsp;个人中心</a></li>
			  <li class="active">微信自动回复</li>
			</ol>
		</div>  
<hr>
{{$this->Form->create('WxAutoReply',array('class'=>'form-horizontal','role'=>'form'))}}

<?php
	if(!empty($this->data['WxAutoReply']['msg_type'])) {
		$_REQUEST['type'] = $this->data['WxAutoReply']['msg_type'];  
	}

?>
		        

	<div class="form-group form-inline">
		<label class="col-sm-2 control-label" for="WxAutoReplyKeyword">关键字 <span style="color:red;">*</span></label>
		<div class="col-sm-9 controls">
			{{$this->Form->input('keyword',array('class'=>'form-control','placeholder'=>'直接输入关键字或者选择系统事件','required'=>'required','div'=>false,'label'=>false))}}
			{{$this->Form->hidden('name')}}
			{{$this->Form->hidden('referer',array('value'=>'/wx_auto_replies/mine'))}}
			&nbsp;&nbsp; 
			<select id="system-event" class="form-control">
				<option value="">选择系统事件</option>
				<option value="subscribe">关注自动回复</option>
				<option value="default">默认自动回复</option>
			</select>
		</div>
	</div>	
	
	
		
	{{$this->Form->hidden('id')}}
	{{$this->Form->hidden('msg_type',array('value'=>$_REQUEST['type']))}}

	{{if $_REQUEST['type'] == 'text'}}
		<div class="form-group">
			<label class="col-sm-2 control-label" for="WxAutoReplySummary">消息内容 <span style="color:red;">*</span></label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('summary',array('class'=>'form-control','required'=>'required','rows'=>6,'div'=>false,'label'=>false))}}
			</div>
		</div>
		
	{{elseif $_REQUEST['type'] == 'news' || $_REQUEST['type'] == 'link'}}
		
		<div>
		  <ul class="nav nav-tabs" role="tablist" style="padding-left: 17%;">
		    <li role="presentation" class="active"><a href="#news-weixin" aria-controls="home" role="tab" data-toggle="tab">微信图文素材</a></li>
		    <li role="presentation"><a href="#news-custom" aria-controls="profile" role="tab" data-toggle="tab">其他</a></li>
		  </ul>
		
		  <!-- Tab panes -->
		  <div class="tab-content"  style="padding:15px 0;">
		    <div role="tabpanel" class="tab-pane active" id="news-weixin">
				<div class="form-group" id="divWxMenuSlug">
					<label class="col-sm-2 control-label" for="WxMenuKey">图文素材 <span style="color:red;">*</span></label>
					<div class="col-sm-9 controls">
						{{$this->Form->input('media_id',array('class'=>'form-control','required'=>'required','readonly'=>'readonly', 'type'=>'text','div'=>false,'label'=>false))}}
						<p style="color:red;">从微信素材库选择</p>
						<p><a href="javascript:void(0)" class="btn btn-primary btn-sm" onclick="publishController.open_dialog('/wx_msgs/wechat?type=select&m=news&inajax=1',{'selector':'#wechat-msg-mine-list',width:900,title:'选择微信素材',callback:function($dialog){$dialog.find('.choose-media').click(function(){ $('#WxAutoReplyMediaId').val( $(this).data('mid') );$dialog.modal('hide');}) } });" >选择素材</a></p>
					</div>
				</div>
			</div>
		    <div role="tabpanel" class="tab-pane" id="news-custom">
		    	<div class="form-group">
					<label class="col-sm-2 control-label" for="WxAutoReplyName">图文消息标题  <span style="color:red;">*</span></label>
					<div class="col-sm-9 controls">
						
						{{$this->Form->input('name',array('class'=>'form-control','div'=>false,'label'=>false))}}
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label" for="WxAutoReplySummary">消息摘要</label>
					<div class="col-sm-9 controls">
						{{$this->Form->input('summary',array('class'=>'form-control','rows'=>6,'div'=>false,'label'=>false))}}
					</div>
				</div>
				<div class="form-group" id="divWxAutoReplyLink">
					<label class="col-sm-2 control-label" for="WxAutoReplyUrl">打开url地址 <span style="color:red;">*</span></label>
					<div class="col-sm-9 controls">
						{{$this->Form->input('url',array('class'=>'form-control','div'=>false,'label'=>false))}}
					</div>
				</div>
				
				<div class="form-group" id="divWxAutoReplySlug">
					<label class="col-sm-2 control-label" for="WxAutoReplyKey">图文消息封面图片  <span style="color:red;">*</span> </label>
					<div class="col-sm-9 controls">
						{{$this->Swfupload->load('coverimg',array('class'=>'form-control',
						'modelClass'=>'WxAutoReply',
						'no_db'=>1,'upload_limit'=>1,
						'file_types'=> '*.jpg;*.gif;*.png;*.bmp',
						'isadmin'=>false,
						'div'=>false,'label'=>false))}}
					</div>
				</div>
				
				<div class="form-group" id="divWxAutoReplySlug">
					<label class="col-sm-2 control-label" for="WxAutoReplyKey">多图文顺序</label>
					<div class="col-sm-9 controls">
						{{$this->Form->input('priority',array('class'=>'form-control','default'=>1,'div'=>false,'label'=>false))}}
						<p>大的排在前面</p>
					</div>
				</div>
		    </div>
		  </div>
		
		</div>

		
		
		
		
	
	{{elseif $_REQUEST['type'] == 'image' }}
		<div class="form-group" id="divWxMenuSlug">
			<label class="col-sm-2 control-label" for="WxMenuKey">图片素材 <span style="color:red;">*</span></label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('media_id',array('class'=>'form-control','required'=>'required','readonly'=>'readonly','type'=>'text','div'=>false,'label'=>false))}}
				<p style="color:red;">回复内容需要从微信素材库选择</p>
				<p><a href="javascript:void(0)" class="btn btn-primary btn-sm" onclick="publishController.open_dialog('/wx_msgs/wechat?type=select&m=image&inajax=1',{'selector':'#wechat-msg-mine-list',width:900,title:'选择微信素材',callback:function($dialog){$dialog.find('.choose-media').click(function(){ $('#WxAutoReplyMediaId').val( $(this).data('mid') );$dialog.modal('hide');}) } });" >选择素材</a></p>
				
				{{if $this->data['WxAutoReply']['media_id']}}
					<img src="/wx_msgs/wechat_thumb?mid={{$this->data['WxAutoReply']['media_id']}}">
				{{/if}}
				
			</div>
		</div>
	{{elseif $_REQUEST['type'] == 'music'}}
		<div class="form-group" id="divWxMenuSlug">
			<label class="col-sm-2 control-label" for="WxMenuKey">音乐封面 <span style="color:red;">*</span></label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('media_id',array('class'=>'form-control','required'=>'required','readonly'=>'readonly','type'=>'text','div'=>false,'label'=>false))}}
				<p style="color:red;">音乐封面需要从微信素材库选择</p>
				<p><a href="javascript:void(0)" class="btn btn-primary btn-sm" onclick="publishController.open_dialog('/wx_msgs/wechat?type=select&m=image&inajax=1',{'selector':'#wechat-msg-mine-list',width:900,title:'选择微信素材',callback:function($dialog){$dialog.find('.choose-media').click(function(){ $('#WxAutoReplyMediaId').val( $(this).data('mid') );$dialog.modal('hide');}) } });" >选择素材</a></p>
				{{if $this->data['WxAutoReply']['media_id']}}
					<img src="/wx_msgs/wechat_thumb?mid={{$this->data['WxAutoReply']['media_id']}}">
				{{/if}}
			</div>
		</div>
		<div class="form-group" id="divWxAutoReplyLink">
			<label class="col-sm-2 control-label" for="WxAutoReplyUrl">音乐文件地址 <span style="color:red;">*</span></label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('url',array('class'=>'form-control','required'=>'required','div'=>false,'label'=>false))}}
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label" for="WxAutoReplyName">音乐标题 </label>
			<div class="col-sm-9 controls">
				
				{{$this->Form->input('name',array('class'=>'form-control','div'=>false,'required'=>'required','label'=>false))}}
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label" for="WxAutoReplySummary">音乐描述</label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('summary',array('class'=>'form-control','rows'=>6,'div'=>false,'label'=>false))}}
			</div>
		</div>
	
	{{elseif $_REQUEST['type'] == 'voice'}}
		<div class="form-group" id="divWxMenuSlug">
			<label class="col-sm-2 control-label" for="WxMenuKey">语音素材 <span style="color:red;">*</span></label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('media_id',array('class'=>'form-control','required'=>'required','type'=>'text','div'=>false,'label'=>false))}}
				<p style="color:red;">回复内容需要从微信素材库选择</p>
				<p><a href="javascript:void(0)" class="btn btn-primary btn-sm" onclick="publishController.open_dialog('/wx_msgs/wechat?type=select&m=voice&inajax=1',{'selector':'#wechat-msg-mine-list',width:900,title:'选择微信素材',callback:function($dialog){$dialog.find('.choose-media').click(function(){ $('#WxAutoReplyMediaId').val( $(this).data('mid') );$dialog.modal('hide');}) } });" >选择素材</a></p>
			</div>
		</div>
	
	{{elseif $_REQUEST['type'] == 'video'}}
		<div class="form-group" id="divWxMenuSlug">
			<label class="col-sm-2 control-label" for="WxMenuKey">视频素材 <span style="color:red;">*</span></label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('media_id',array('class'=>'form-control','required'=>'required','readonly'=>'readonly', 'type'=>'text','div'=>false,'label'=>false))}}
				<p style="color:red;">回复内容需要从微信素材库选择</p>
				<p><a href="javascript:void(0)" class="btn btn-primary btn-sm" onclick="publishController.open_dialog('/wx_msgs/wechat?type=select&m=video&inajax=1',{'selector':'#wechat-msg-mine-list',width:900,title:'选择微信素材',callback:function($dialog){$dialog.find('.choose-media').click(function(){ $('#WxAutoReplyMediaId').val( $(this).data('mid') );$dialog.modal('hide');}) } });" >选择素材</a></p>
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-2 control-label" for="WxAutoReplyName">视频标题</label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('name',array('class'=>'form-control','div'=>false,'label'=>false))}}
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label" for="WxAutoReplySummary">视频摘要</label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('summary',array('class'=>'form-control','rows'=>6,'div'=>false,'label'=>false))}}
			</div>
		</div>
		
	{{/if}}

	<div class="form-group">
			<label class="col-sm-2 control-label" for="WxAutoReplySummary">其它词</label>
			<div class="col-sm-9 controls">
				{{$this->Form->hidden('WxSimilar.id',array('value'=>$similar['WxSimilar']['id']))}}
				{{$this->Form->input('WxSimilar.words',array('class'=>'form-control','value'=>$similar['WxSimilar']['words'],'rows'=>3,'div'=>false,'label'=>false))}}
				<small>一行一个，当用户发送内容与词匹配时，也自动回复对应的消息。</small>
			</div>
		</div>
		
	
	<div class="form-group">
		<label class="col-sm-2 control-label"></label>
		<div class="col-sm-9"><input class="btn btn-primary" type="submit" value="提交"></div>
	</div>
	{{$this->Form->end()}}

<script>

$(function(){
	$('#system-event').change(function(){
		if($(this).val() != ""){
			$('#WxAutoReplyKeyword').val($(this).val());
			$('#WxAutoReplyName').val( $("option:selected",this).text() );
		}
		else{
			$('#WxAutoReplyName').val( "" );
			$('#WxAutoReplyKeyword').val("");
		}
		
	})
});

</script>